export default {
  namespaced: true,
  state: {
    num: 10,
    items: []
  },
  mutations: {
    ADD_NUM (state, n) {
      state.num += n
    },
    REDUCE_NUM (state, n) {
      state.num -= n
    },
    INIT_ITEMS (state, items) {
      state.items = items
    }
  },
  actions: {
    FETCH_ITEMS ({ commit }) {
      setTimeout(() => {
        const items = ['商品1', '商品2', '商品3']
        commit('INIT_ITEMS', items)
      }, 2000)
    }
  }
}
